package com.example.demo.mapper;

import com.example.demo.entity.AfBrand;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Mr.We
 * @since 2024-06-21
 */
@Mapper
public interface AfBrandMapper extends BaseMapper<AfBrand> {
    @Select("select * from nideshop_brand where id = #{id}")
    AfBrand queryObject(@Param("id")Integer id);

    @Select("<script>" +
            "select" +
            "        <if test='fields != null and fields != null'>" +
            "            ${fields}" +
            "        </if>" +
            "        <if test='fields == null or fields == null'>" +
            "            *" +
            "        </if>" +
            "        from af_brand" +
            "        <choose>" +
            "            <when test='sidx != null and sidx.trim() != null'>" +
            "                order by ${sidx} ${order}" +
            "            </when>" +
            "            <otherwise>" +
            "                order by id desc" +
            "            </otherwise>" +
            "        </choose>" +
            "        <if test='offset != null and limit != null'>" +
            "            limit #{offset}, #{limit}" +
            "        </if>" +
            "</script>")
    List<AfBrand> queryList(Map<String, Object> map);
    int queryTotal(Map<String, Object> map);
}
